﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Data;
using System.Globalization;
using System.Windows;

namespace BDSim
{
    public class RecFreSetViewModel : INotifyPropertyChanged
    {
        #region 字段
        private List<ERecType> _RecType = new List<ERecType>() { { ERecType.BD }, { ERecType.GPS }, { ERecType.GLONASS }, { ERecType.GALILEO } };
        private ERecType _RecTypeSelected = ERecType.BD;
        private List<EFrePoint> _RecFreList = new List<EFrePoint>() { EFrePoint.BD_B1 };


        #endregion 字段
        /// <summary>
        /// 接收机类型
        /// </summary>
        public List<ERecType> RecTypeList
        {
            get { return _RecType; }
            set { _RecType = value; }
        }

        /// <summary>
        /// 接收机类型的选择类型
        /// </summary>
        public ERecType RecTypeSelected
        {
            get { return _RecTypeSelected; }
            set { _RecTypeSelected = value; NotifyChanged("RecTypeSelected"); }
        }
        /// <summary>
        /// 接收机的频率列表
        /// </summary>
        public List<EFrePoint> RecFreList
        {
            get { return _RecFreList; }
            set { _RecFreList = value; }
        }


        #region 属性值更改通知事件
        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
        #endregion
    }

    #region 数据类型转换接口的实现类
    public class BD2TypeToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility vi = Visibility.Collapsed;
            if ((ERecType)value == ERecType.BD)
            {
                vi = Visibility.Visible;
            }

            return vi;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class GPSTypeToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility vi = Visibility.Collapsed;
            if ((ERecType)value == ERecType.GPS)
            {
                vi = Visibility.Visible;
            }

            return vi;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class GLONASSTypeToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility vi = Visibility.Collapsed;
            if ((ERecType)value == ERecType.GLONASS)
            {
                vi = Visibility.Visible;
            }

            return vi;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class GALILEOTypeToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility vi = Visibility.Collapsed;
            if ((ERecType)value == ERecType.GALILEO)
            {
                vi = Visibility.Visible;
            }

            return vi;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public class BD2_GPSTypeToVisibility : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility vi = Visibility.Collapsed;
            if ((ERecType)value == ERecType.BD_GPS)
            {
                vi = Visibility.Visible;
            }

            return vi;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    //public class RecTypeStringToRecTypeEnum : IValueConverter
    //{

    //    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        string type = "";
    //        switch ((ERecType)value)
    //        {
    //            case ERecType.BD:
    //                type = "BD";
    //                break;
    //            case ERecType.GPS:
    //                type = "GPS";
    //                break;
    //            case ERecType.GLONASS:
    //                type = "GLONASS";
    //                break;
    //            case ERecType.GALILEO:
    //                type = "GALILEO";
    //                break;
    //            case ERecType.BD_GPS:
    //                type = "BD_GPS";
    //                break;
    //            default:
    //                break;
    //        }
    //        return type;
    //    }

    //    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        ERecType type = new ERecType();
    //        switch (value.ToString())
    //        {
    //            case "BD":
    //                type = ERecType.BD;
    //                break;
    //            case "GPS":
    //                type = ERecType.GPS;
    //                break;
    //            case "GLONASS":
    //                type = ERecType.GLONASS;
    //                break;
    //            case "GALILEO":
    //                type = ERecType.GALILEO;
    //                break;
    //            case "BD_GPS":
    //                type = ERecType.BD_GPS;
    //                break;
    //            default:
    //                break;
    //        }
    //        return type;
    //    }
    //}
    #endregion 数据类型转换接口的实现类
}
